/**
 * 
 */
package com.bms.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.ModelAndView;

import com.bms.Logic;
import com.bms.abstracts.RESTController;
import com.bms.domain.Event;
import com.bms.domain.User;
import com.bms.domain.profile.Profile;

/**
 * @author IBM
 *
 */
public class EventController extends RESTController {
	
	private Logic logic;
	
	public void setLogic(Logic logic) {
		this.logic = logic;
	}

	/* (non-Javadoc)
	 * @see com.bms.abstracts.RESTController#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected ModelAndView doGet(HttpServletRequest request,
			HttpServletResponse response) {
		
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute("user");
		
		int row = 10;
		if(null!=request.getParameter("row") && !"".equals(request.getParameter("row"))){
			row = Integer.parseInt(request.getParameter("row"));
		}
		
		List<Event> gzjh = logic.getEventList(user.getId(), Profile.GONG_ZUO_JI_HUA, row);
		List<Event> gzzj = logic.getEventList(user.getId(), Profile.GONG_ZUO_ZONG_JIE, row);
		List<Event> yyhd = logic.getEventList(user.getId(), Profile.YAN_CHU_HUO_DONG_AN_PAI, row);
		
		request.setAttribute("gzjh", gzjh);
		request.setAttribute("gzzj", gzzj);
		request.setAttribute("yyhd", yyhd);
		
		return new ModelAndView("event");
	}

	/* (non-Javadoc)
	 * @see com.bms.abstracts.RESTController#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected ModelAndView doPost(HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub
		return null;
	}

}
